package Z02IOStream.W03ByteStream;

import java.io.*;

public class TestByteStream {
    public static void main(String[] args) throws IOException {


        try {
            // 准备文件lol.txt 内容AB，
            File f = new File("c:/lol.txt");
            // 创建字符输入流
            FileInputStream fis = new FileInputStream(f);
            // 创建字符数组，长度是文件长度
            byte[] all = new byte[(int)f.length()];
            // 以字节流形式读取文件所有内容
            fis.read(all);
            for (Byte b :all){
                // 打印65 ，66
                System.out.println(b);
            }
            // 每次使用流，都应该进行关闭
            fis.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}

class TestByteStream1{

    public static void main(String[] args) throws IOException {

        try {
            File f = new File("c:/Lol2.exe");
            byte data[] = {88,89};
            FileOutputStream fos;
            fos = new FileOutputStream(f);

            fos.write(data);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }







}
